package com.whitehot.klib.engine;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * Created by ytf on 2017/3/20 020.
 * Description: 线程池
 */

public class ThreadManager
{
    private static ThreadManager instance;

    static final int EXECUTOR_THREADS = Runtime.getRuntime().availableProcessors();

    ExecutorService es;

    private ThreadManager()
    {
        es = Executors.newCachedThreadPool();
    }

    public static ThreadManager getInstance()
    {
        if(instance == null)
        {
            synchronized(ThreadManager.class)
            {
                if(instance == null)
                {
                    instance = new ThreadManager();
                }
            }
        }
        return instance;
    }

    public ExecutorService get()
    {
        return es;
    }
}
